{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import mfm.portfolioopt as pfopt\n",
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# np.save(\"./data/covariance_matrix.npy\", model_covariance)\n",
    "# np.save(\"./data/return.npy\",R)\n",
    "\n",
    "\n",
    "cov_mat=np.load(\"./data/covariance_matrix.npy\")\n",
    "avg_rets=np.load(\"./data/return.npy\")\n",
    "target_ret=0.001\n",
    "calc_weights = pfopt.markowitz_portfolio(pd.DataFrame(cov_mat), pd.Series(avg_rets), target_ret).values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1.03641993e-01, 2.73722595e-06, 8.20599462e-02, 3.52779013e-07,\n",
       "       4.26297506e-07, 4.93147795e-02, 2.84200167e-07, 2.75426191e-02,\n",
       "       4.40984703e-02, 1.95320174e-02, 1.44261976e-06, 5.04045020e-07,\n",
       "       3.48305049e-07, 2.01545996e-04, 8.91640507e-07, 2.51233900e-02,\n",
       "       4.59923819e-07, 3.11036401e-07, 5.39803647e-02, 1.03358058e-02,\n",
       "       1.37881333e-02, 4.62195928e-02, 4.38026466e-02, 8.00119911e-02,\n",
       "       8.22715214e-07, 4.32816071e-07, 4.08471881e-02, 3.72295065e-06,\n",
       "       4.26890686e-06, 1.89370721e-07, 2.38051708e-02, 4.00033822e-02,\n",
       "       4.18833777e-07, 1.95563499e-02, 3.48343731e-06, 4.26905817e-02,\n",
       "       2.70356632e-02, 2.17171188e-02, 9.56575614e-07, 4.18436474e-02,\n",
       "       7.78060140e-03, 2.41246585e-07, 4.25069391e-02, 5.69084720e-07,\n",
       "       1.65095633e-06, 7.65547048e-07, 2.48199747e-02, 7.24761249e-07,\n",
       "       4.31433729e-02, 2.45707089e-02])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "calc_weights"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
